package com.duan.search.controller;

import com.duan.entity.Result;
import com.duan.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * ES商品查询
 */
@RestController
@RequestMapping("/search")
public class SearchController {
    @Autowired
    private SearchService searchService;

    /**
     * 关键词查询
     * @param paramMap
     * @return
     */
    @PostMapping("/select")
    public Result search(@RequestBody Map<String, String> paramMap){
        try{
            Map map = searchService.search(paramMap);
            return Result.ok("查询成功",map);
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }
}
